package com.jtlrm.ckd.mvp.view.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.base.sdk.app.GlideApp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jtlrm.ckd.R;
import com.jtlrm.ckd.entity.ShiWuTypeEntity;

public class ShiWuTypeAdapter extends BaseQuickAdapter<ShiWuTypeEntity, BaseViewHolder> {

    int selectPosition = 0;

    public ShiWuTypeAdapter() {
        super(R.layout.shi_wu_type_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, ShiWuTypeEntity item) {
        helper.setText(R.id.food_name, item.getFoodTypeName());
        GlideApp.with(mContext).load(item.getImagePath()).fitCenter().into((ImageView) helper.getView(R.id.food_image));
        if (selectPosition == helper.getLayoutPosition()) {
            helper.getView(R.id.item).setBackgroundResource(R.color.text_green);
            helper.setTextColor(R.id.food_name, mContext.getResources().getColor(R.color.white));
        } else {
            helper.getView(R.id.item).setBackgroundResource(R.color.grey_100);
            helper.setTextColor(R.id.food_name, mContext.getResources().getColor(R.color.text_black));
        }
    }

    public void setSelectPosition(int select) {
        if (select != selectPosition) {
            selectPosition = select;
            notifyDataSetChanged();
        }
    }

}
